package com.yq.cp.service.basics.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.yq.cp.config.MyException;
import com.yq.cp.config.UserThreadLocal;
import com.yq.cp.entity.basics.*;
import com.yq.cp.entity.common.PageVo;
import com.yq.cp.entity.permission.User;
import com.yq.cp.mapper.basics.*;
import com.yq.cp.service.basics.TotalSettlementService;
import com.yq.cp.utils.DateTimeUtil;
import com.yq.cp.utils.PdfPageUtil;
import com.yq.cp.utils.wx.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.List;

/**
 * <p>
 * 结算总表 服务实现类
 * </p>
 *
 * @author shenyuqing
 * @since 2024-08-27
 */
@Service
public class TotalSettlementServiceImpl extends ServiceImpl<TotalSettlementMapper, TotalSettlement> implements TotalSettlementService {
    @Resource
    TotalSettlementMapper totalSettlementMapper;
    @Value("${notify.url}")
    private String url;
    @Resource
    GridSettlementUnitPriceMapper gridSettlementUnitPriceMapper;
    @Resource
    OrganizationalStructureMapper organizationalStructureMapper;
    @Resource
    DwjsdjMapper dwjsdjMapper;
    @Resource
    BillingInformationSettingsMapper billingInformationSettingsMapper;
    @Override
    public TotalSettlement detail(TotalSettlement totalSettlement) {
        TotalSettlement one = totalSettlementMapper.selectById(totalSettlement.getId());
        //渠道商
        OrganizationalStructure channel = organizationalStructureMapper.selectById(one.getChannelMerchantsId());
        one.setChannelMerchantsName(channel.getName());
        //所在大区
        OrganizationalStructure region = organizationalStructureMapper.selectById(one.getRegionId());
        one.setRegionName(region.getName());
        GridSettlementUnitPrice gridSettlementUnitPrice = gridSettlementUnitPriceMapper.selectOne(new QueryWrapper<GridSettlementUnitPrice>()
                .eq("total_settlement_id", one.getId()));
        one.setGridSettlementUnitPrice(gridSettlementUnitPrice);
        return one;
    }

    @Override
    public IPage<TotalSettlement> selList(PageVo pageVo) {
        IPage<TotalSettlement> page = new Page<>(pageVo.getPage(), pageVo.getSize());
        User user = UserThreadLocal.get();
        pageVo.setUserId(user.getId());
        page = totalSettlementMapper.selLists(page,pageVo);
        return page;
    }

    @Override
    public Map wxFee(TotalSettlement totalSettlement) {
        User user = UserThreadLocal.get();
        TotalSettlement byId = totalSettlementMapper.selectById(totalSettlement);
        Map<String,Object> map=new HashMap<>();
        String fee=byId.getZjsdf().multiply(new BigDecimal(100)).intValue()+"";
        String orderNumber= CommonUtil.generateOrderId();//订单号
        byId.setFee(byId.getZjsdf());
        byId.setOutTradeNo(orderNumber);
        byId.setUserId(user.getId());
        byId.setAccount(user.getUsername());
        byId.setUsername(user.getNickname());
        byId.setPhone(user.getPhone());
        totalSettlementMapper.updateById(byId);
        try {
            MyWXPayConfig wxPayConfig = new MyWXPayConfig();
            WXPay wxPay = new WXPay(wxPayConfig);
            Map<String, String> data = new HashMap<>();
            data.put("body", "购买商品");
            data.put("out_trade_no", orderNumber);
            String nonceStr = WXPayUtil.generateNonceStr();
            data.put("nonce_str", nonceStr);
            data.put("fee_type", "CNY");
//            String format = DateTimeUtil.format(DateTimeUtil.dqsj(), "yyyy-MM-dd'T'HH:mm:ssXXX");
//            data.put("time_expire",format);
            data.put("openid", user.getOpenId());
            data.put("total_fee", fee);
            data.put("spbill_create_ip", "127.0.0.1");
            data.put("trade_type", "JSAPI");//JSAPI
            data.put("notify_url", url + "/wx/callback");
            Map<String, String> result = wxPay.unifiedOrder(data);
            if (result != null) {
                String returnMsg = result.get("return_msg");
                String returnCode = result.get("return_code");
                if ("OK".equals(returnMsg) && "SUCCESS".equals(returnCode)) {
                    String code_url = result.get("code_url");
                    Map<String, String> resultMap = new HashMap<>();
                    resultMap.put("appId", result.get("appid"));
                    resultMap.put("timeStamp", WXPayUtil.getCurrentTimestamp() + "");
                    resultMap.put("nonceStr", nonceStr);
                    resultMap.put("package", "prepay_id=" + result.get("prepay_id"));
                    SignType signType = SignType.MD5;
                    resultMap.put("signType", signType.name());
                    String signature = null;
                    signature = WXPayUtil.generateSignature(resultMap, wxPayConfig.getKey(), signType);
                    resultMap.put("paySign", signature);
                    resultMap.put("orderId", orderNumber);
                    resultMap.put("codeUrl", code_url);
                    map.put("payMessage",resultMap);
                    map.put("time", DateTimeUtil.getStrDateTime(DateTimeUtil.dqsj()));
                    map.put("zfzt",0);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new MyException("生成微信支付订单失败");
        }
        return map;

    }

    @Override
    public Page<TotalSettlement> record(PageVo vo) {
        User user = UserThreadLocal.get();
        Page<TotalSettlement> page = new Page<>(vo.getPage(), vo.getSize());
        QueryWrapper<TotalSettlement> wrapper = new QueryWrapper<>();
        if (!Objects.isNull(vo.getId()))
            wrapper.eq("site_id",vo.getId());
        if (!Objects.isNull(vo.getYear()))
            wrapper.eq("year",vo.getYear());
        if (!Objects.isNull(vo.getMonth()))
            wrapper.eq("month",vo.getMonth());
        wrapper.eq("fee_state",1);
        wrapper.eq("user_id",user.getId());
        page = totalSettlementMapper.selectPage(page,wrapper);
        return page;
    }

    @Override
    public IPage<TotalSettlement> selListUser(PageVo pageVo) {
        IPage<TotalSettlement> page = new Page<>(pageVo.getPage(), pageVo.getSize());
        page = totalSettlementMapper.selListUser(page,pageVo);
        return page;
    }

    @Override
    public TotalSettlement details(TotalSettlement totalSettlement) {
        TotalSettlement one = totalSettlementMapper.selectById(totalSettlement.getId());
        //渠道商
        OrganizationalStructure channel = organizationalStructureMapper.selectById(one.getChannelMerchantsId());
        one.setChannelMerchantsName(channel.getName());
        //所在大区
        OrganizationalStructure region = organizationalStructureMapper.selectById(one.getRegionId());
        one.setRegionName(region.getName());
        List<Dwjsdj> dwjsdjs = dwjsdjMapper.selectList(new QueryWrapper<Dwjsdj>()
                .eq("total_settlement_id", one.getId()));
//        GridSettlementUnitPrice gridSettlementUnitPrice = gridSettlementUnitPriceMapper.selectOne(new QueryWrapper<GridSettlementUnitPrice>()
//                .eq("total_settlement_id", one.getId()));
        List<BillingInformationSettings> settings = billingInformationSettingsMapper.selectList(new QueryWrapper<BillingInformationSettings>()
                .eq("total_settlement_id", one.getId()));
        one.setBillingInformationSettings(settings);
        one.setDwjsdjs(dwjsdjs);
//        one.setGridSettlementUnitPrice(gridSettlementUnitPrice);
        return one;
    }

    @Override
    public void downloads(TotalSettlement totalSettlement, HttpServletResponse response) {
        TotalSettlement one = totalSettlementMapper.selectById(totalSettlement.getId());
        //渠道商
        OrganizationalStructure channel = organizationalStructureMapper.selectById(one.getChannelMerchantsId());
        one.setChannelMerchantsName(channel.getName());
        //所在大区
        OrganizationalStructure region = organizationalStructureMapper.selectById(one.getRegionId());
        one.setRegionName(region.getName());
        User user = UserThreadLocal.get();
        List<Dwjsdj> dwjsdjs = dwjsdjMapper.selectList(new QueryWrapper<Dwjsdj>().eq("total_settlement_id", one.getId()));
        GridSettlementUnitPrice gridSettlementUnitPrice = gridSettlementUnitPriceMapper.selectOne(new QueryWrapper<GridSettlementUnitPrice>()
                .eq("total_settlement_id", one.getId()));
        one.setGridSettlementUnitPrice(gridSettlementUnitPrice);

        // 定义全局的字体静态变量
        //定义全局字体静态变量
        Font titlefont;
        Font headfont = null;
        Font headfont1 = null;
        Font keyfont = null;
        Font textfont = null;
        Font textfont1 = null;
        Font content = null;
        Font space = null;
        Font space1 = null;
        Font space2 = null;
        Font space3 = null;
        // 最大宽度
        try {
            // 不同字体（这里定义为同一种字体：包含不同字号、不同style）
            BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            titlefont = new Font(font, 16, Font.BOLD);
            //四号
            headfont = new Font(font, 14, Font.BOLD);
            headfont1 = new Font(font, 14, Font.NORMAL);
            //三号
            content = new Font(font, 16, Font.NORMAL);
            //小四
            //textfont = new Font(font, 11, Font.BOLD);
            textfont = new Font(font, 8, Font.BOLD);
            textfont1 = new Font(font, 11, Font.NORMAL);
            space = new Font(font, 2, Font.NORMAL);
            space1 = new Font(font, 10, Font.NORMAL);
            space2 = new Font(font, 30, Font.NORMAL);
            space3 = new Font(font, 20, Font.NORMAL);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BaseFont bf;
        Font font = null;
        try {
            //创建字体
            bf = BaseFont.createFont( "STSong-Light", "UniGB-UCS2-H",
                    BaseFont.NOT_EMBEDDED);
            //使用字体并给出颜色
            font = new Font(bf,20,Font.BOLD,BaseColor.BLACK);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //纵向
        Document document = new Document(new RectangleReadOnly(595F,842F));
        //横向
        //Document document = new Document(new RectangleReadOnly(842F, 595F));
        //设置页边距  60:左边距，60：右边距，72：上边距，72：下边距
        document.setMargins(60, 60, 72, 72);
        try{
            PdfWriter writer = PdfWriter.getInstance(document,response.getOutputStream());
            PdfPCell cell = null;
            //添加页码
            writer.setPageEvent(new PdfPageUtil());
            //打开生成的pdf文件
            document.open();


            //第一个表格
            // 设置表格的列宽和列数
            float[] widths = {25f,25f,25f,25f,25f,25f,25f,25f,25f};
            PdfPTable table = new PdfPTable(widths);
            table.setSpacingBefore(10f);
            // 设置表格宽度为100%
            table.setWidthPercentage(100.0F);
            table.setHeaderRows(1);
            table.getDefaultCell().setHorizontalAlignment(1);

            //第一行
            cell = new PdfPCell(new Paragraph("客户名称",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getSiteName(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("客户户号",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getAccountNumber(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(8);
            cell.setRowspan(6);
            table.addCell(cell);
            //第二行
            cell = new PdfPCell(new Paragraph("发电地址",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPowerGenerationAddress(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(8);
            cell.setRowspan(1);
            table.addCell(cell);

            //第三行
            cell = new PdfPCell(new Paragraph("发电单位",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPowerGenerationUnit(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(8);
            cell.setRowspan(1);
            table.addCell(cell);

            //第四行
            cell = new PdfPCell(new Paragraph("结算周期",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime3(one.getSettlementCycleBegin()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(2);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("至",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime3(one.getSettlementCycleOver()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("制表员",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZby(),textfont));
            //cell = new PdfPCell(new Paragraph(one.getPowerGenerationUnit()));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("制表时间",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(DateTimeUtil.getStrDateTime3(one.getCreateTime()),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            //第五行
            cell = new PdfPCell(new Paragraph("本期总发电量",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("千瓦时",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("本期消纳总电量",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("千瓦时",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("本期结算总电费",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("元",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table.addCell(cell);

            //第六行
            cell = new PdfPCell(new Paragraph("客户代表\n(签字)",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(""));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(2);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("发电单位代表\n(签字)",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(""));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("确认日期",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(""));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(8);
            cell.setRowspan(6);
            table.addCell(cell);
            Paragraph  paragraph = new Paragraph("分布式光伏发电站电费结算单",content);
            paragraph.setAlignment(Element.ALIGN_CENTER);
            document.add(paragraph);
            document.add(table);
            //第二个表格
            float[] widths2 = {25f,25f,25f,25f,25f,25f,25f};
            PdfPTable table2 = new PdfPTable(widths2);
            table2.setSpacingBefore(20f);
            // 设置表格宽度为100%
            table2.setWidthPercentage(100.0F);
            table2.setHeaderRows(1);
            table2.getDefaultCell().setHorizontalAlignment(1);
            //第一行
            cell = new PdfPCell(new Paragraph("计量时段",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);


            cell = new PdfPCell(new Paragraph("单位",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("总",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("尖",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("峰",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("平",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("谷",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第二行
            cell = new PdfPCell(new Paragraph("总发电量",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("kWh",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGzfdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);
            //第三行
            cell = new PdfPCell(new Paragraph("上网电量",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("kWh",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZswdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJswdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFswdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPswdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGswdl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第四行
            cell = new PdfPCell(new Paragraph("客户消纳电量",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("kWh",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZkhxndl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJkhxndl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFkhxndl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPkhxndl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGkhxndl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第五行
            cell = new PdfPCell(new Paragraph("电网结算单价",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("kWh/元",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("/",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJdwjsdj().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFdwjsdj().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPdwjsdj().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGdwjsdj().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第六行
            cell = new PdfPCell(new Paragraph("客户消纳电费",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("元",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZkhxndf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJkhxndf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFkhxndf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPkhxndf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGkhxndf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);
            //第七行
            cell = new PdfPCell(new Paragraph("折扣比例",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("%",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("/",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJzkbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFzkbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPzkbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGzkbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第八行
            cell = new PdfPCell(new Paragraph("结算电费",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("元",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);


            cell = new PdfPCell(new Paragraph(one.getGjsdf().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第九行
            cell = new PdfPCell(new Paragraph("消纳比例",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("%",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGxnbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            //第十行
            cell = new PdfPCell(new Paragraph("上网比例",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("%",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getZswbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getJswbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getFswbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getPswbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph(one.getGswbl().toString(),textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table2.addCell(cell);

            Paragraph paragraph1 = new Paragraph("计费信息",content);
            paragraph1.setAlignment(Element.ALIGN_CENTER);
            document.add(new Paragraph("\n"));
            document.add(paragraph1);
            //document.add(new Paragraph("\n"));
            document.add(table2);
            //dwjsdjs
            //第三个表格
//            float[] widths3 = new float[6];
//            for (int i = 0; i < 6; i++) {
//                widths3[i] = 25f;
//            }
            float[] widths3 = {40f,25f,25f,25f,25f,25f};
            PdfPTable table3 = new PdfPTable(widths3);
            table3.setSpacingBefore(10f);
            // 设置表格宽度为100%
            table3.setWidthPercentage(100.0F);
            table3.setHeaderRows(1);
            table3.getDefaultCell().setHorizontalAlignment(1);

            //第一行
            cell = new PdfPCell(new Paragraph("计量时段",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);
            //第一行
            cell = new PdfPCell(new Paragraph("单位",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);

            //第二行
            cell = new PdfPCell(new Paragraph("尖峰",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);
            //第三行
            cell = new PdfPCell(new Paragraph("高峰",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);
            //第四行
            cell = new PdfPCell(new Paragraph("平段",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);
            //第五行
            cell = new PdfPCell(new Paragraph("低谷",textfont));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(15);
            table3.addCell(cell);
            for(int i = 0;i<dwjsdjs.size();i++){
                if (i== 0){
                    cell = new PdfPCell(new Paragraph("    "+dwjsdjs.get(0).getTitle(),textfont));
                }else {
                    cell = new PdfPCell(new Paragraph("              "+dwjsdjs.get(i).getTitle(),textfont));
                }
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
                cell.setFixedHeight(15);
                table3.addCell(cell);

                cell = new PdfPCell(new Paragraph("kWh/元",textfont));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setFixedHeight(15);
                table3.addCell(cell);

                cell = new PdfPCell(new Paragraph(dwjsdjs.get(i).getJfnum().toString(),textfont));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setFixedHeight(15);
                table3.addCell(cell);

                cell = new PdfPCell(new Paragraph(dwjsdjs.get(i).getGfnum().toString(),textfont));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setFixedHeight(15);
                table3.addCell(cell);

                cell = new PdfPCell(new Paragraph(dwjsdjs.get(i).getPdnum().toString(),textfont));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setFixedHeight(15);
                table3.addCell(cell);

                cell = new PdfPCell(new Paragraph(dwjsdjs.get(i).getDgnum().toString(),textfont));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setFixedHeight(15);
                table3.addCell(cell);

            }
//            for (Dwjsdj dwjsdj : dwjsdjs) {
//                cell = new PdfPCell(new Paragraph("    "+dwjsdj.getTitle(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//
//                cell = new PdfPCell(new Paragraph("kWh/元",textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//
//                cell = new PdfPCell(new Paragraph(dwjsdj.getJfnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//
//                cell = new PdfPCell(new Paragraph(dwjsdj.getGfnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//
//                cell = new PdfPCell(new Paragraph(dwjsdj.getPdnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//
//                cell = new PdfPCell(new Paragraph(dwjsdj.getDgnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(15);
//                table3.addCell(cell);
//            }


//            for (Dwjsdj dwjsdj : dwjsdjs) {
//                cell = new PdfPCell(new Paragraph(dwjsdj.getJfnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(30);
//                table3.addCell(cell);
//            }



//            for (Dwjsdj dwjsdj : dwjsdjs) {
//                cell = new PdfPCell(new Paragraph(dwjsdj.getGfnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(30);
//                table3.addCell(cell);
//            }



//            for (Dwjsdj dwjsdj : dwjsdjs) {
//                cell = new PdfPCell(new Paragraph(dwjsdj.getPdnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(30);
//                table3.addCell(cell);
//            }


//
//            for (Dwjsdj dwjsdj : dwjsdjs) {
//                cell = new PdfPCell(new Paragraph(dwjsdj.getDgnum().toString(),textfont));
//                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                cell.setFixedHeight(30);
//                table3.addCell(cell);
//            }
            Paragraph paragraph2 = new Paragraph("电网结算单价构成",content);
            paragraph2.setAlignment(Element.ALIGN_CENTER);
            document.add(new Paragraph("\n"));
            document.add(paragraph2);
            //document.add(new Paragraph("\n"));
            document.add(table3);

            document.close();
        }catch (DocumentException | IOException e){
            e.printStackTrace();
            log.error("导出pdf失败:{}",e);
        }

    }


}
